package com.wsmhz.web.controller;

import com.wsmhz.exception.UserException;
import com.wsmhz.security.core.common.ServerResponse;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.ResponseStatus;

/**
 * create by tangbj on 2018/3/25
 * 自定义异常处理器
 */
@ControllerAdvice
public class ControllerExceptionHandler {

    @ExceptionHandler(UserException.class)
    @ResponseBody
    @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
    public ServerResponse<String> handleUserNotExistException(UserException ex) {
        return ServerResponse.createByErrorMessage("用户不存在");
    }

}
